package Controle;

import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import javax.swing.JComboBox;
import javax.swing.JOptionPane;

import DAO.TCCDao;
import POJO.TCC;



public class ctrlTCC 
{

	public JComboBox<String> BuscaTCC(JComboBox<String> cmbTCC)
	{
		if(cmbTCC.getItemCount() != 0)
		{
			cmbTCC.removeAllItems();
		}
		List<TCC> listaTCC = new ArrayList<TCC>();
		TCCDao tDao = new TCCDao();
		try 
		{
			listaTCC = tDao.listaTCC();
			for(TCC tcc:listaTCC)
			{
				StringBuffer sTCC = new StringBuffer();
				sTCC.append(String.valueOf(tcc.getCodTCC()));
				sTCC.append(" - ");
				sTCC.append(tcc.getTema());
				cmbTCC.addItem(sTCC.toString());				
			}
		} catch (SQLException e) 
		{
			JOptionPane.showMessageDialog(null, e.getMessage(), "Erro na listagem de TCCs", JOptionPane.ERROR_MESSAGE);
		}
		return cmbTCC;		
	}
}
